export default class CustomContextPad {
    private bpmnFactory: any;
    private create: any;
    private elementFactory: any;
    private translate: any;
    private modeling: any;
    static $inject: string[];
    constructor(config: any, contextPad: any, create: any, elementFactory: any, injector: any, translate: any, modeling: any, bpmnFactory: any) {
        this.create = create;
        this.elementFactory = elementFactory;
        this.translate = translate;
        this.modeling = modeling;
        this.bpmnFactory = bpmnFactory;
        contextPad.registerProvider(this); // // 定义这是一个contextPad
    }

    getContextPadEntries(element: any) {
        const {
            translate,
            modeling
        } = this;
        // 删除功能
        function removeElement() {
            modeling.removeElements([element]);
        }

        function deleteElement() {
            return {
                group: 'edit',
                className: ["bpmn:StartEvent", "bpmn:EndEvent", "label"].includes(element.type) ? '' : 'bpmn-icon-trash',
                title: translate('删除'),
                action: {
                    click: removeElement
                }
            };
        }

        return {
            delete: deleteElement()
        };
    }
}

CustomContextPad.$inject = [
    'config',
    'contextPad',
    'create',
    'elementFactory',
    'injector',
    'translate',
    'modeling',
    'bpmnFactory'
];
